import type {
  AuxiliaryInputQueryListParams,
  AuxiliaryInputSaveOrUpdateParams,
} from '@/types'

export const defaultFormData: Partial<AuxiliaryInputSaveOrUpdateParams>
  = {
    dataTime: '',
    yield: 0,
    outputValue: 0,
    productUnitConsumptionTarget: 0,
    outputValueUnitConsumptionTarget: 0,
  }

export const formRules
  = generateCurrencyFormRules(defaultFormData)

export const shortcuts = [
  {
    text: '当年',
    value: () => {
      const end = new Date()
      const start = new Date(new Date().getFullYear(), 0)
      return [start, end]
    },
  },
  {
    text: '最近一年',
    value: () => {
      const end = new Date()
      const start = new Date()
      start.setMonth(start.getMonth() - 11)
      return [start, end]
    },
  },
]

export const defaultQuery: Partial<AuxiliaryInputQueryListParams>
  = (() => {
    const [startTime, endTime] = shortcuts[1]?.value()!
    return {
      startTime: formatTime(startTime!, 'YYYY-MM'),
      endTime: formatTime(endTime!, 'YYYY-MM'),
    }
  })()
